package cn.micai.base;

import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.List;

/**
 * 描述：
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/4/13 14:18
 */
public class CityTreetTest {

    // 例子
    public static void main(String[] args) {
        CityTree cityTree4 = new CityTree();
        cityTree4.setId("1000");
        cityTree4.setName("山东省");
        cityTree4.setpId("0");
        CityTree cityTree = new CityTree();
        cityTree.setId("1001");
        cityTree.setName("潍坊市");
        cityTree.setpId("1000");
        CityTree cityTree1 = new CityTree();
        cityTree1.setId("1002");
        cityTree1.setName("青岛市");
        cityTree1.setpId("1000");
        CityTree cityTree2 = new CityTree();
        cityTree2.setId("1001001");
        cityTree2.setName("高新区");
        cityTree2.setpId("1001");
        CityTree cityTree3 = new CityTree();
        cityTree3.setId("1002001");
        cityTree3.setName("四方区");
        cityTree3.setpId("1002");
        CityTree cityTree5 = new CityTree();
        cityTree5.setId("1001001001");
        cityTree5.setName("清池街办");
        cityTree5.setpId("1001001");
        CityTree cityTree6 = new CityTree();
        cityTree6.setId("1001001002");
        cityTree6.setName("**街办");
        cityTree6.setpId("1002001");
        List<CityTree> cityTreeList = new ArrayList<>();
        cityTreeList.add(cityTree);
        cityTreeList.add(cityTree1);
        cityTreeList.add(cityTree2);
        cityTreeList.add(cityTree3);
        cityTreeList.add(cityTree4);
        cityTreeList.add(cityTree5);
        cityTreeList.add(cityTree6);
        CityTreeUtils.createTree(cityTreeList, cityTree4,"id","pId","cityTrees");
        System.out.println(JSONObject.toJSON(cityTree4)); //通过上边的createTree方法，根节点，即cityTree4就是最全的最后的树结构。
    }
}
